package gui;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.*;

import components.DevLst;
import components.IOBuffer.InputBuffer;
import components.exceptions.InputBufferExceedException;


public class MyInput extends JScrollPane {

	public static InputBuffer keyboardInputBuffer = new InputBuffer();

	static class InputArea extends JTextArea {
		InputArea() {

			this.setBorder(null);
			this.setVisible(true);
			this.setCaretColor(new Color(86,173,164));
			this.setCaret(getCaret());
			this.setFont(new Font("Serif", Font.ITALIC, 14));
		//	this.setForeground(new Color(115, 225, 122, 50));
		//	this.setBackground(new Color(0,0,0,0));// TODO: change this color
			this.setForeground(Color.yellow);
			this.setBackground(Color.black);
			this.setOpaque(true);

			this.addKeyListener(new KeyListener() {

				@Override
				public void keyPressed(KeyEvent arg0) {
					// TODO Auto-generated method stub

				}

				@Override
				public void keyReleased(KeyEvent arg0) {
					// TODO Auto-generated method stub

				}

				@Override
				public void keyTyped(KeyEvent arg0) {
					keyboardInputBuffer.putIntoBuffer(arg0.getKeyChar());

					// the following line makes the input of the input console
					// directly goes into the output buffer.
					// TODO: remember to comment it
					DevLst.getInstance().list.get(1).putIntoBuffer(
							arg0.getKeyChar());
				}

			});
		}
	}

	public MyInput() {
		super(new InputArea());

		this.setBorder(null);
		this.setVisible(true);
		this.setOpaque(false);
		this.setForeground(Color.blue);

	}
}
